package com.czk.model.iterator;

import java.util.Iterator;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/5/11 20:15
 */
public class ComputerCollegeIterator implements Iterator {
    // 存储的形式
    private Department[] departments;
    // 遍历的位置
    private int position=0;
    @Override
    public boolean hasNext() {
        if (position>=departments.length||departments[position]==null){
            return false;
        }
        return true;
    }

    @Override
    public Object next() {
        Department department=departments[position];
        position++;
        return department;
    }
    // 删除的方法默认空实现

    @Override
    public void remove() {

    }

    public ComputerCollegeIterator(Department[] departments) {
        this.departments = departments;
    }
}
